package com.xjnt.frameworks.plugin.sql.criterion;

import java.io.Serializable;

import com.xjnt.frameworks.core.BaseModel;
import com.xjnt.frameworks.plugin.sql.consts.FetchMode;

public class Relation implements Serializable {

	private static final long serialVersionUID = 1L;
	private BaseModel<?> modelClass;
	private String tableName;
	private String alias;
	private FetchMode fetchMode;

	protected Relation(BaseModel<?> modelClass, String tableName, String alias, FetchMode fetchMode) {
		this.modelClass = modelClass;
		this.tableName = tableName;
		this.alias = alias == null ? modelClass.getModelName() : alias;
		this.fetchMode = fetchMode;
	}

	public Relation(BaseModel<?> modelClass, String alias) {
		this(modelClass, alias, FetchMode.NONE);
	}
	
	public Relation(BaseModel<?> modelClass, String alias, FetchMode fetchMode) {
		this(modelClass, null, alias, fetchMode);
	}

	public Relation(String tableName, String alias) {
		this(null, tableName, alias, FetchMode.NONE);
	}

	public BaseModel<?> getModelClass() {
		return modelClass;
	}
	
	public String getTableName() {
		return tableName;
	}

	public String getAlias() {
		return alias;
	}
	
	public FetchMode getFetchMode() {
		return fetchMode;
	}

}
